package com.wyl.controller

import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.HttpRequestHandler
import org.springframework.web.bind.annotation.RequestMapping
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

@Controller
//@RestController //用来返回json数据
class HelloController{
    init {
        println("HelloController初始化成功")
    }

//    这个注解不行
    @RequestMapping("/hello")
    fun hello(model: Model): String {
        println("访问了hello接口")
        model.addAttribute("msg", "Hello, SpringMVC Annotation")
        return "hello"
    }

//    这个方式可以
//    override fun handleRequest(request: HttpServletRequest, response: HttpServletResponse) {
//        println("访问了hello接口")
//    }

}